
# 导入基类
from base.base import Base
from selenium.webdriver.common.by import By
from time import sleep

# 导入页面类继承基类
class DeletePage(Base):

    # 定位商品管理
    goodsmanager = (By.XPATH, '//span[text()="商场管理"]')
    def clickgoodsmanager(self):
        self.loc_ele(self.goodsmanager).click()
    # 定位关键词
    delete = (By.XPATH, '//span[text()="关键词"]')
    def clickdelete(self):
        self.loc_ele(self.delete).click()
    # 定位添加品牌制造商的按钮
    # deletebutton  = (By.CSS_SELECTOR, '"#app > div > div.sidebar-container.el-scrollbar > div.scrollbar-wrapper.el-scrollbar__wrap > div > ul > div:nth-child(2) > li > ul > div:nth-child(2) > a > li > span"')
    # def clickdeletebutton(self):
    #     self.loc_ele(self.deletebutton).click()


    # 定位问题输入框
    # proleminput = (By.CLASS_NAME, "el-input__inner")
    # def inputprolemcontent(self, c):
    #     eles = self.loc_eles(self.proleminput)
    #     ele = eles[3]
    #     ele.send_keys(c)

    # # 定位回复输入框
    # inputreplycontent = (By.CLASS_NAME, "el-textarea__inner")
    # def inputreplycontentbusiness(self, c):
    #     ele = self.loc_ele(self.inputreplycontent)
    #     ele.send_keys(c)

    # 定位确定按钮
    deletebutton  = (By.XPATH, '/html/body/div/div/div[2]/section/div/div[2]/div[3]/table/tbody/tr[1]/td[6]/div/button[2]/span')
    def clickdeletebutton(self):
        self.loc_ele(self.deletebutton).click()

    # 断言用到的元素
    dy = (By.XPATH, '//table[@class="el-table__body"]/tbody/tr[1]/td[2]/div')
    def getdycontent(self):
        return self.loc_ele(self.dy).text

    # 断言用到的元素
    dy2 = (By.CLASS_NAME, "el-form-item__error")
    def getdy2content(self):
        return self.loc_ele(self.dy2).text

    # 操作业务的方法
    def shanchubusiness(self, q, r):
        # 点击商品管理
        self.clickgoodsmanager()
        sleep(1)
        # 点击关键词菜单
        self.clickdelete()
        sleep(1)
        # # 点击添加按钮
        # self.clicktianjiabutton()
        # # 输入问题
        # self.inputprolemcontent(q)
        # # 输入回复
        # # self.inputreplycontentbusiness(r)
        # sleep(2)
        # 点击删除按钮
        self.clickdeletebutton()
        sleep(3)